*===============================================================================
*=== FILE 8 --- RENT REGRESSIONS
*===============================================================================
clear all
set more off

cap cd ""


cap log close
log using "replication output/regressions_rent", replace


use "replication output\rent_regression_data", clear

* Create interactions (use the "for-sale listing" based index. Similar results using the "for-rent listing" based index)

gen ln_index_zipcode_year       = ln(index_zipcode_year_FS + 0.01)
gen ln_index_zipcode_year_uw6ft = uw6ft * ln_index_zipcode_year

gen ln_index_zipcode_quarter       = ln(index_zipcode_quarter_FS + 0.01)
gen ln_index_zipcode_quarter_uw6ft = uw6ft * ln_index_zipcode_quarter

gen index_zipcode_year_uw6ft    = uw6ft * index_zipcode_year_FS
gen index_zipcode_quarter_uw6ft = uw6ft * index_zipcode_quarter_FS

* Label
label variable ln_index_zipcode_year    "ln(Index by Zip-Year)"
label variable ln_index_zipcode_quarter "ln(Index by Zip-Quarter)"

label variable ln_index_zipcode_year_uw6ft    "Flood Zone x ln(Index by Zip-Year)"
label variable ln_index_zipcode_quarter_uw6ft "Flood Zone x ln(Index by Zip-Quarter)"

label variable index_zipcode_year_FS    "Index by Zip-Year"
label variable index_zipcode_quarter_FS "Index by Zip-Quarter"

label variable index_zipcode_year_uw6ft    "Flood Zone x Index by Zip-Year"
label variable index_zipcode_quarter_uw6ft "Flood Zone x Index by Zip-Quarter"

*label variable ln_transaction_price "ln(Transaction Price)"
label variable uw6ft                "Flood Zone"


eststo: reghdfe ln_rental_price uw6ft ln_index_zipcode_year_uw6ft   , absorb(apt3 finishedsquarefeet_pct lotsizesquarefeet_pct prop_age_group remodel_age_group bedroomcnt bathroomcnt zip_quarter_fe) vce(cluster zip_quarter)
eststo: reghdfe ln_rental_price uw6ft ln_index_zipcode_quarter_uw6ft, absorb(apt3 finishedsquarefeet_pct lotsizesquarefeet_pct prop_age_group remodel_age_group bedroomcnt bathroomcnt zip_quarter_fe) vce(cluster zip_quarter)
eststo: reghdfe ln_rental_price uw6ft ln_index_zipcode_year_uw6ft   , absorb(propertyid zip_quarter_fe) vce(cluster zip_quarter)
eststo: reghdfe ln_rental_price uw6ft ln_index_zipcode_quarter_uw6ft, absorb(propertyid zip_quarter_fe) vce(cluster zip_quarter)
eststo: reghdfe ln_rental_price uw6ft index_zipcode_year_uw6ft      , absorb(apt3 finishedsquarefeet_pct lotsizesquarefeet_pct prop_age_group remodel_age_group bedroomcnt bathroomcnt zip_quarter_fe) vce(cluster zip_quarter)
eststo: reghdfe ln_rental_price uw6ft index_zipcode_quarter_uw6ft   , absorb(apt3 finishedsquarefeet_pct lotsizesquarefeet_pct prop_age_group remodel_age_group bedroomcnt bathroomcnt zip_quarter_fe) vce(cluster zip_quarter)
eststo: reghdfe ln_rental_price uw6ft index_zipcode_year_uw6ft      , absorb(propertyid zip_quarter_fe) vce(cluster zip_quarter)
eststo: reghdfe ln_rental_price uw6ft index_zipcode_quarter_uw6ft   , absorb(propertyid zip_quarter_fe) vce(cluster zip_quarter)


* Now for coefficients
tostring bathroomcnt, gen(br_str) format(%4.1f)
encode br_str, gen(br)
eststo: reghdfe ln_rental_price uw6ft ln_index_zipcode_year_uw6ft i.apt3 i.finishedsquarefeet_pct i.lotsizesquarefeet_pct ///
                                      i.prop_age_group i.remodel_age_group i.bedroomcnt i.br, ///
									  absorb(zip_quarter_fe) vce(cluster zip_quarter)
cap log close
